//package com.warren.aspect;
//
//import com.warren.exception.BusinessException;
//import org.aspectj.lang.annotation.Aspect;
//import org.aspectj.lang.annotation.Before;
//import org.aspectj.lang.annotation.Pointcut;
//import org.springframework.stereotype.Component;
//import org.springframework.web.context.request.RequestContextHolder;
//import org.springframework.web.context.request.ServletRequestAttributes;
//import org.springframework.web.util.ContentCachingRequestWrapper;
//
//import javax.servlet.http.HttpServletRequest;
//import java.io.IOException;
//import java.nio.charset.StandardCharsets;
//import java.util.Map;
//import java.util.Objects;
//
///**
// * @author warren
// * @data: 2022/3/26 10:11 PM
// * @decription:
// */
//@Component
//@Aspect
//public class SignAspect {
//    private static final String SIGN_HEADER = "X-SIGN";
//
//    @Pointcut()
//    private void verifySignPointCut() {
//
//    }
//
//    @Before("verifySignPointCut()")
//    public void verify() {
//        HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
//        String sign = request.getHeader(SIGN_HEADER);
//
//        //must have sign in header
//        if (sign.isEmpty()) {
//            throw new BusinessException("no signature in header: " + SIGN_HEADER);
//        }
//
//    }
//
//    private String generatedSignature(HttpServletRequest request) throws IOException {
//        String bodyParam = null;
//        if (request instanceof ContentCachingRequestWrapper) {
//            bodyParam = new String(((ContentCachingRequestWrapper) request).getContentAsByteArray(), StandardCharsets.UTF_8);
//            Map<String, String[]> requestParameterMap = request.getParameterMap();
//        }
//    }
//}
